<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.*,
com.brother.model.*" pageEncoding="utf-8"%>
<jsp:useBean id="carmodelService" class="com.brother.service.CarModelService"></jsp:useBean>
<%


String action = request.getParameter("action");
if(action != null && action.equalsIgnoreCase("delete")){
	String carmodelid = request.getParameter("carmodelid");
	carmodelService.deleteCarmodel(carmodelid);
}

List<CarModel> models = carmodelService.getAllCarModels();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>manage all car models</title>
<link href="../common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../common.js"></script>
</head>
<body>
<form name="form1" method="post" action="">
	<table width="100%"><tr><td height="30"><div align="left"><a href="addModel.jsp">Add Model </a></div></td></tr></table>
  <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#00CCFF">
    
    <tr>
      <th width="181" height="30" bgcolor="#FFFFFF"><div align="center">name</div></th>
      <th width="845" bgcolor="#FFFFFF"><div align="center">description</div></th>
      <th width="171" bgcolor="#FFFFFF">manage</th>
    </tr>
    <%for(int i = 0; i < models.size(); i++){ %>
    <tr>
      <td bgcolor="#FFFFFF"><div align="center"><%=models.get(i).getName() %></div></td>
      <td bgcolor="#FFFFFF"><div align="center" style="overflow-y:scroll;height:100px;text-align:left;"><%=models.get(i).getDescription().replace("document.designMode = 'on';","")%></div></td>
      <td bgcolor="#FFFFFF"><div align="center">
      <a onClick="return checkDel();" href="carmodels.jsp?action=delete&carmodelid=<%=models.get(i).getCarmodelId()%>">Delete</a>
      <a  href="addModel.jsp?action=edit&carModelId=<%=models.get(i).getCarmodelId()%>">Modify</a>
      </div></td>
    </tr>
    <%} 
    if(models.size() == 0){%>
       <tr>
      <td bgcolor="#FFFFFF" colspan="3"><div align="center">no models found.</div></td>
    </tr> 
    <%} %>    
  </table>
</form>



</body>
</html>